package cn.kgc.springmvc.controller;

import cn.kgc.springmvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

/**
 * @author: mosin
 * @version: v1.0  2022/5/6
 */
@Controller
@RequestMapping("/user")
@SessionAttributes("user")
public class UserController {

    //登录
    @RequestMapping("/login")
    public  String login(Model model){
        System.out.println("登录请求接收" );
        model.addAttribute("msg", "登录成功");
        User user = new User();
        user.setPassword("123");
        user.setUserName("tom");
        model.addAttribute("user", user);
        return "success";
    }

    //注册
    @RequestMapping("/register")
    public  String register(Model model){
        System.out.println("注册请求接收" );
        model.addAttribute("msg", "注册成功");
        return "success";
    }
    // 添加
    @RequestMapping("/add")
    public  String add(Model model){
        System.out.println("添加请求接收" );
        model.addAttribute("msg", "添加成功");
        return "success";
    }

    //删除
    @RequestMapping("/delete")
    public  String delete(Model model){
        System.out.println("删除请求接收" );
        model.addAttribute("msg", "删除成功");
        return "success";
    }
    // 修改
    @RequestMapping("/update")
    public  String update(Model model){
        System.out.println("更新请求接收" );
        model.addAttribute("msg", "更新成功");
        return "success";
    }

}
